<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        img {
            width: 40px;
        }
    </style>
</head>

<body>
    <h1>数据展示</h1>
    
    <a href="/m1/add" type="button" class="btn btn-success">添加成员</a>
    <a style="float: right;" type="button" class="btn btn-warning" href="/m1/logout">退出登录</a>
    
    <table class="table table-bordered table-hover">
        <thead>
            <tr>
                <th>编号</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>头像</th>
                <th>点赞</th>
                <th>是否交好友</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {{each arr}}
            <tr>
                <td>{{$value._id}}</td>
                <td>{{$value.name}}</td>
                <td>{{$value.age}}</td>
                <td><img src="{{$value.avatar}}" alt="" onerror="this.src='zan.png'"></td>
                <td>
                    <img src="{{$value.like?'zan.png':'no-zan.png'}}" alt="">
                </td>
                <td>
                    {{if $value.friend}}
                    <p>是</p>
                    {{else}}
                    <p>否</p>
                    {{/if}}
                </td>
                <td>
                    <!-- a标签只支持get方式     {{@ $value._id}}实现去除上引号 -->
                    <a href="/m1/doDelete?id={{@ $value._id}}"  type="button" class="btn btn-danger">删除</a>        
                    <a href="/m1/edit?id={{@ $value._id}}" type="button" class="btn btn-danger">修改</a>        
                </td>
            </tr>
            {{/each}}
        </tbody>
    </table>

</body>

</html>